package com.system.coupon.controller;

import com.system.coupon.enums.BizCodeEnum;
import com.system.coupon.model.R;
import com.system.coupon.request.LockCouponRecordRequest;
import com.system.coupon.service.CouponRecordService;
import com.system.coupon.util.JsonData;
import com.system.coupon.vo.CouponRecordVO;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 二当家小D
 * @since 2021-02-07
 */
@RestController
@RequestMapping("/sys/coupon_record")
public class CouponRecordController {
    @Autowired
    CouponRecordService couponRecordService;
    @PostMapping("lock_records")
    public JsonData lockCouponRecords(@RequestBody LockCouponRecordRequest recordRequest){
        JsonData jsonData = couponRecordService.lockCouponRecords(recordRequest);
        return jsonData;

    }

    @GetMapping("/detail/{record_id}")
    public JsonData detail(@PathVariable long record_id){
        CouponRecordVO couponRecordVO = couponRecordService.findById(record_id);

        return couponRecordVO == null ? JsonData.buildResult(BizCodeEnum.COUPON_NO_EXITS):JsonData.buildSuccess(couponRecordVO);
    }

}

